/**
 * 用户注册-隐私条款内容-ANTA-PC端
 */
var agreementHtml = '';
function showAgreement(show) {
  if (!show) {
    layer.closeAll();
    return;
  }
  if (agreementHtml === '') {
    try {
      MALL.Common.showLoading();
    } catch (error) {}
    $.ajax({
      type: 'POST',
      url: MALL.Common.url.agree_list || '/antacom/data.User/getAgreeList',
      data: {},
      dataType: 'json',
      success: function (data) {
        try {
          MALL.Common.hideLoading();
        } catch (error) {}
        if (data.status == 1 && data.data && data.data.length > 0) {
          agreementHtml = '<div class="ql-editor">' + data.data[0].agreement + '</div>';
          openAgreement();
        } else {
          try {
            MALL.Common.message({ text: '加载失败，请重试' || data.msg, time: 2000 });
          } catch (error) {}
        }
      },
      error: function (res) {
        try {
          MALL.Common.hideLoading();
          MALL.Common.message({ text: '加载失败，请重试' || data.msg, time: 2000 });
        } catch (error) {}
      },
    });
    return;
  }
  openAgreement();
}
function openAgreement() {
  /** 显示弹窗 */
  layer.open({
    type: 1,
    title: false, //不显示标题栏
    closeBtn: false,
    area: ['65%', '80%'],
    shade: 0.8,
    id: 'LAY_layuipro', //设定一个id，防止重复弹出
    resize: false,
    btn: ['同意', '关闭'],
    btnAlign: 'c',
    moveType: 1, //拖拽模式，0或者1
    content: agreementHtml,
    success: function (layero) {
      var btn = layero.find('.layui-layer-btn');
      btn.find('.layui-layer-btn0').attr({
        onclick: 'successAgreement();',
      });
    },
  });
}
function successAgreement() {
  $('input[name=agree]').prop('checked', true);
  console.log('Success');
  layer.closeAll();
}
